<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>用户管理 | {$system_name}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="{_ADMIN_STATIC_}/i/favicon.png">
    <link rel="stylesheet" href="{_ADMIN_STATIC_}/css/amazeui.min.css" />
    <link rel="stylesheet" href="{_ADMIN_STATIC_}/css/admin.css">
    <link rel="stylesheet" href="{_ADMIN_STATIC_}/css/app.css">

</head>

<body data-type="index">
    <!-- 头部导航栏 -->
    {include file='public/header'}
    <!-- 左侧侧边栏 -->
    {include file='public/side'}
    <!-- 中间内容开始 -->

    <!-- 标题 -->
    <div class="tpl-content-page-title">
        {$system_name} -- 角色管理
    </div>
    <!-- 面包屑导航 -->
    <ol class="am-breadcrumb">
        <li><a href="{:url('Role/index')}" class="am-icon-home">角色管理</a></li>
        <li>角色编辑</li>
    </ol>
    <!-- 提示信息 -->
    <div class="tpl-content-scope">
        <div class="note note-info">
            <h3> 角色编辑
                <span class="close" data-close="note"></span>
            </h3>
            <p>角色编辑</p>
            <p><span class="label label-danger">提示:</span>
                编辑某一个具体的角色的所有信息
            </p>
        </div>

        <div class="tpl-portlet-components">

            <div class="tpl-block ">
                <div class="am-g tpl-amazeui-form">

                    <div class="am-u-sm-12 am-u-md-9">
                        <div class="am-form am-form-horizontal">

                            <div class="am-form-group">
                                <label for="name" class="am-u-sm-3 am-form-label">角色名称 / Name</label>
                                <div class="am-u-sm-9">
                                    <input type="text" id="name" value="{$role_info.name}" placeholder="角色名称 / Name">
                                    <small></small>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label for="status" class="am-u-sm-3 am-form-label">角色状态 / Status</label>
                                <div class="am-u-sm-9">
                                    <select id="status">
                                        {volist name="role_status" id="row"}
                                        {if condition="$row.value == $role_info.status"}
                                        <option value="{$row.value}" selected>{$row.name}</option>
                                        {else/}
                                        <option value="{$row.value}">{$row.name}</option>
                                        {/if}
                                        {/volist}
                                    </select>
                                    <small></small>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label for="note" class="am-u-sm-3 am-form-label">备注 / Note</label>
                                <div class="am-u-sm-9">
                                    <textarea name="" id="note" cols="30" rows="3"
                                        placeholder="备注 / Note">{$role_info.note}</textarea>
                                    <small></small>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <div class="am-u-sm-9 am-u-sm-push-3">
                                    <button type="button" class="am-btn am-btn-primary" onclick="save()">保存修改</button>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>


    <!-- 中间内容结束 -->
    <!-- 底部 -->
    <!-- {include file="public/footer"} -->

    <script src="{_ADMIN_STATIC_}/lib/jquery/jquery.js"></script>
    <script src="{_ADMIN_STATIC_}/js/amazeui.min.js"></script>
    <script src="{_ADMIN_STATIC_}/js/app.js"></script>
    <script src="{_ADMIN_STATIC_}/lib/layer/layer.js"></script>
    <script>

        // 保存修改
        function save() {

            // ID
            var id = "{$role_info.id}";
            // 角色名称
            var name = $('#name').val().trim();
            // 角色状态
            var status = $('#status').val().trim();
            // 备注
            var note = $('#note').val().trim();

            var data = {
                'id': id,
                'name': name,
                'status': status,
                'note': note
            };

            $.ajax({
                url: "{:url('Role/role_edit')}",
                data: data,
                type: "POST",
                dataType: "JSON",
                success: function (res) {
                    // 返回结果处理
                    if (res.code == 0) {
                        return layer.msg(res.msg, { icon: 1, time: 900 });
                    } else {
                        return layer.msg(res.msg, { icon: 2, time: 900 });
                    }
                }
            });

        }

        // 重定向
        function redirect_url(url) {
            window.location.href = url;
        }

    </script>
</body>

</html>